<?php
function login(){
	$email = $_POST["email"];
	$passwort = md5($_POST["passwort"]);

	$abfrage = "SELECT email, passwort, name, vorname FROM user WHERE email='".mysql_real_escape_string($email)."' LIMIT 1";
	$ergebnis = mysql_query($abfrage);
	$row = mysql_fetch_object($ergebnis);
	$name = $row->name;
	$vorname = $row->vorname;
	
	if($row->passwort == $passwort){		
		setCookieOwn();
		setSessionOwn();
		return '1';
	}
	else{
    	return '2';
    } 
}

function loginSession($email, $pass){

	$abfrage = "SELECT email, passwort, name, vorname FROM user WHERE email='".mysql_real_escape_string($email)."' LIMIT 1";
	$ergebnis = mysql_query($abfrage);
	$row = mysql_fetch_object($ergebnis);
	$name = $row->name;
	$vorname = $row->vorname;
	
	if($row->passwort == $pass)
    {		
		return '1';
	}else {
		return '2';
	}
	
}

function logOut(){
	?><a href="logout.php?log">Ausloggen</a><?php
}
?>
<?php
function getUserID($email){
	$abfrage = "SELECT ID FROM user WHERE email='".mysql_real_escape_string($email)."' LIMIT 1";
	$ergebnis = mysql_query($abfrage);
	$row = mysql_fetch_object($ergebnis);
	return $row->ID;
}
?>